#include<bits/stdc++.h>
using namespace std;
const int maxn=1e8;
bool prime[maxn];
int main()
{
	memset(prime,true,sizeof(prime)); 
	int i,j,a,b,sum=0;
	cin>>a>>b;
	if(a>b)
	swap(a,b);
	for(i=2;i<=b;i++)
	{
		if(prime[i])
		{
			for(j=i*i;j<=b;j+=i)
			prime[j]=false;
		}
	}
	for(i=a;i<=b;i++)
	{
		if(i<=1) continue;
		if(prime[i]) sum+=i;
	}
	cout<<sum;
    return 0;
}
